package com.ftg.learn.chapter04;

import java.util.Arrays;

/**
 * 数组
 *
 * @author lijiaxin
 * @version 1.0
 * @date 2023/5/27 15:23
 */

public class LearnArray01 {
    public static void main(String[] args) {
        Dog d = new Dog();
        d.setName("孙宝贵");

        //GC : 如何确认垃圾 (算法[计数法 | 根可达])
        Dog d1 = new Dog();
        d1.setName("王春花");

        d1 = d;

        //引用类型

//        声明、创建、初始化
        Dog[] dogs = new Dog[]{d1,d};

        //== 判断是否为同一个地址
        System.out.println(dogs[0] == d1);

        System.out.println(d == d1);

        int[] a = new int[10];

        //赋值  10 ....
        for (int i = 0,v =1; i < a.length; i++) {
            a[i] = v+=2;
        }
        System.out.println(Arrays.toString(a));

        for (int i = 0; i < a.length; i++) {
            while(true){
                int v = (int)(Math.random() * 98 + 3);
                if(v % 2 != 0){
                    a[i] = v;
                    break;
                }
            }
        }
        //去掉重复的
        System.out.println(Arrays.toString(a));
    }
}
